package cn.ylz.ylmall.order.dao.persist.repository.impl;

import cn.ylz.ylmall.order.dao.persist.mapper.OrderDetailMapper;
import cn.ylz.ylmall.order.dao.persist.repository.OrderDetailRepository;
import cn.ylz.ylmall.order.pojo.entity.OrderDetail;
import cn.ylz.ylmall.order.pojo.vo.OrderDetailVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author pc
 */
@Slf4j
@Repository
public class OrderDetailRepositoryImpl implements OrderDetailRepository {

    @Autowired
    private OrderDetailMapper orderDetailMapper;

    @Override
    public int insert(OrderDetail orderDetail) {
        log.debug("开始repository新增操作");
        return orderDetailMapper.insertAll(orderDetail);
    }

    @Override
    public OrderDetail selectOrderVO(String orderNo) {
        log.debug("开始执行查询数据库操作");
        return orderDetailMapper.selectOrder(orderNo);
    }

    @Override
    public int deleteOrder(String orderNo) {
        log.debug("开始执行删除订单操作");
        return orderDetailMapper.deleteByOrderNo(orderNo);
    }

    @Override
    public int updateOrder(Map<String, Object> paramMap) {
        log.debug("开始执行修改订单操作");
        return orderDetailMapper.updateOrderDetail(paramMap);
    }

    /**
     * 查询订单列表
     *
     * @param userId
     * @return
     */
    @Override
    public List<OrderDetail> selectOrderList(QueryWrapper<OrderDetail> queryWrapper) {
        log.debug("开始执行查询订单列表操作");
        return orderDetailMapper.selectList(queryWrapper);
    }
}
